package router

import (
	jwt "gitee.com/sansaniot/ssiot-core/httpmvc/jwtauth"
	"github.com/gin-gonic/gin"

	"ssdevice/internal/device/apis"
)

func init() {
	RouterCheckRole = append(RouterCheckRole, registerGatewayRouter)
}

func registerGatewayRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
	api := apis.Gateway{}
	// 硬网关
	r := v1.Group("/api/gateway").Use(authMiddleware.MiddlewareFuncWithOutValidate())
	{
		r.GET("/find", api.FindList)
		r.GET("/get", api.FindOne)
		r.POST("/add", api.AddGateway)
		r.POST("/modify", api.EditGateway)
		r.POST("/remove", api.DeleteGateway)
		r.POST("/changeGroup", api.ChangeGroup)
		r.POST("/save/product", api.GatewaySaveProduct)
		r.POST("/config/save", api.UpsertEntireConfig)
		// 下发配置与获取
		r.POST("/config/set", api.SetGatewayConfig)
		r.POST("/config/get", api.GetGatewayConfig)
		// 下发控制
		r.POST("/func/set", api.SendGatewayFunc)
	}
	// 网关历史数据
	r4 := v1.Group("/api/gateway/historydata").Use(authMiddleware.MiddlewareFuncWithOutValidate())
	{
		r4.GET("/find", api.FindGatewayHistoryData)
		r4.GET("/get", api.GetGatewayHistoryData)
	}
}
